package com.school.repair.service;

import com.school.repair.dao.EquipmentDao;
import com.school.repair.entity.Equipment;
import com.school.repair.entity.EquipmentType;
import com.school.repair.util.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
@Service
public class EquipmentService {

    @Resource
    EquipmentDao equipmentDao;

    public List<EquipmentType> findType() {
            return equipmentDao.findType();
    }

    public Page<Equipment> equipmentListBy(int pageNo, int pageSize, long equipmentType, String name, long unitid) {
            List<Equipment> list = equipmentDao.equipmentListBy(pageNo, pageSize, equipmentType, name, unitid);
            int total = equipmentDao.totalBy(equipmentType, name, unitid);
            return new Page<Equipment>(total, list, pageNo);
    }

    public Page<Equipment> equipmentSearch(int pageNo, int pageSize, long equipmentType, String name, long id) {
            List<Equipment> list = equipmentDao.equipmentSearch(pageNo, pageSize, equipmentType, name, id);
            int total = equipmentDao.equipmentSearchTotal(equipmentType, name, id);
            return new Page<Equipment>(total, list, pageNo);
    }

    public Equipment equipmentGet(long id) {
            return equipmentDao.equipmentGet(id);
    }

    public int equipmentUpdate(Equipment equipment) {
            return equipmentDao.equipmentUpdate(equipment);
    }

    public int changeStatus(long id, long status) {
            return equipmentDao.changeStatus(id, status);
    }

    public int unitAddEquipment(Equipment eq) {
            return equipmentDao.unitAddEquipment(eq);
    }

    public int delete(long id) {
            return equipmentDao.delete(id);
    }

    public Page<Equipment> equipmentPaging(int pageNo, int pageSize, Date createdate, String name, long id) {
            List<Equipment> list = equipmentDao.paging(pageNo, pageSize, createdate, name, id);
            int total = equipmentDao.total(createdate, name, id);
            return new Page<Equipment>(total, list, pageNo);
    }


    public int addBarCode(long id, String barCode) {
            return equipmentDao.addBarCode(id, barCode);
    }
}
